package com.kingdee.eas.custom.hr.attendance.app;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.hr.attendance.ZhuanZhenCollection;
import com.kingdee.eas.custom.hr.attendance.ZhuanZhenInfo;
import com.kingdee.eas.framework.CoreBaseCollection;
import java.util.Iterator;
import java.util.Set;
import org.apache.log4j.Logger;

public class ZhuanZhenControllerBean extends AbstractZhuanZhenControllerBean {
	private static Logger logger = Logger
			.getLogger("com.kingdee.eas.custom.hr.attendance.app.ZhuanZhenControllerBean");

	public void saveZhuanZhen(Context ctx, ZhuanZhenInfo zhuanZhen)
			throws BOSException, EASBizException {
		super.saveZhuanZhen(ctx, zhuanZhen);

		Set addSet = (Set) zhuanZhen.get("addSet");
		Set updateSet = (Set) zhuanZhen.get("updateSet");
		Set deleteSet = (Set) zhuanZhen.get("deleteSet");

		Iterator it = addSet.iterator();
		ZhuanZhenInfo info = null;

		ZhuanZhenCollection colls = new ZhuanZhenCollection();
		while (it.hasNext()) {
			info = (ZhuanZhenInfo) it.next();
			colls.add(info);
		}
		_saveBatchData(ctx, colls);

		IObjectPK[] pks = new ObjectUuidPK[deleteSet.size()];
		int i = 0;
		it = deleteSet.iterator();
		while (it.hasNext()) {
			info = (ZhuanZhenInfo) it.next();
			pks[(i++)] = new ObjectUuidPK(info.getId());
		}
		deleteBatchData(ctx, pks);

		CoreBaseCollection collection = new CoreBaseCollection();
		it = updateSet.iterator();
		while (it.hasNext()) {
			info = (ZhuanZhenInfo) it.next();
			collection.add(info);
		}

		updateBatchData(ctx, collection);
	}
}
